set more off

************************************************************************************************************
****************************************Figure S.1***********************************************************
************************************************************************************************************


local rloop = 250
local alpha = 1
local sigma = 1
local sigmax = 1
local N = 20000
local beta=1
local loopcount = 0

*DGP index
*1 == Weitzman
*2 == Satisficing
*3 == Search all goods above a threshold
*4 == Random search

local dgplist = "1 2 3 4"

local Klist="-10 -1 0 1 2 3"

local Jlist = "2 3 5 10 "

forvalues r = 1/`rloop' {
foreach dgp of local dgplist {
foreach J of local Jlist {
foreach K of local Klist{

local loopcount = `loopcount'+1
display "LOOP START!"
display "LOOP START!"
display "LOOP START!"
display "LOOP START!"
display "r is `r'"
display "dgp is `dgp'"
display "K is `K'"
display "J is `J'"

set seed 600`r'

do programs/flexiblelogit.do `alpha' `beta' `sigma' `sigmax' `J' `N' `dgp' `K' 

gen r = `r'
if(`loopcount' > 1) append using simtableK
save simtableK, replace
}
}
}
}




*generate graphs with outside no search shares and alpha estimates

*plot alpha estimate with a horizontal true value line instead x as outnosearchshare y as alpha-1
use simtableK,clear
bys dgp J K:egen meanalpha=mean(alpha)
bys dgp J K:egen meanoutnosearchshare=mean(outnosearchshare) 
keep dgp J K meanalpha meanoutnosearchshare
duplicates drop

twoway scatter meanalpha meanoutnosearchshare, colorvar(J) colordiscrete colorrule(phue) zlabel(, valuelabel) coloruseplegend plegend(order(4 "J=2" 3 "J=3" 2 "J=5" 1 "J=10")) yline(1) yscale(r(0,1)) ylabel(0 0.2 0.4 0.6 0.8 1, grid) xscale(r(0,1))xlabel(0 0.2 0.4 0.6 0.8 1, grid) xtitle("Share not Searching any Inside Good") ytitle("Alpha Estimates")
graph export Kfull.png,replace 
twoway scatter meanalpha meanoutnosearchshare if dgp==1, colorvar(J) colordiscrete colorrule(phue) zlabel(, valuelabel) coloruseplegend plegend(order(4 "J=2" 3 "J=3" 2 "J=5" 1 "J=10")) yline(1) yscale(r(0,1))  ylabel(0 0.2 0.4 0.6 0.8 1, grid)xscale(r(0,1)) xlabel(0 0.2 0.4 0.6 0.8 1, grid) xtitle("Share not Searching any Inside Good") ytitle("Alpha Estimates")
graph export Kdgp1.png ,replace 
twoway scatter meanalpha meanoutnosearchshare if dgp==2, colorvar(J) colordiscrete colorrule(phue) zlabel(, valuelabel) coloruseplegend plegend(order(4 "J=2" 3 "J=3" 2 "J=5" 1 "J=10")) yline(1) yscale(r(0,1)) ylabel(0 0.2 0.4 0.6 0.8 1, grid) xscale(r(0,1)) xlabel(0 0.2 0.4 0.6 0.8 1, grid) xtitle("Share not Searching any Inside Good") ytitle("Alpha Estimates")
graph export Kdgp2.png ,replace 
twoway scatter meanalpha meanoutnosearchshare if dgp==3, colorvar(J) colordiscrete colorrule(phue) zlabel(, valuelabel) coloruseplegend plegend(order(4 "J=2" 3 "J=3" 2 "J=5" 1 "J=10")) yline(1) yscale(r(0,1))  ylabel(0 0.2 0.4 0.6 0.8 1, grid) xscale(r(0,1)) xlabel(0 0.2 0.4 0.6 0.8 1, grid) xtitle("Share not Searching any Inside Good") ytitle("Alpha Estimates")
graph export Kdgp3.png ,replace 
twoway scatter meanalpha meanoutnosearchshare if dgp==4, colorvar(J) colordiscrete colorrule(phue) zlabel(, valuelabel) coloruseplegend plegend(order(4 "J=2" 3 "J=3" 2 "J=5" 1 "J=10")) yline(1) yscale(r(0,1))  ylabel(0 0.2 0.4 0.6 0.8 1, grid)xscale(r(0,1)) xlabel(0 0.2 0.4 0.6 0.8 1, grid) xtitle("Share not Searching any Inside Good") ytitle("Alpha Estimates")
graph export Kdgp4.png ,replace 


